package hwOne2;

import edu.princeton.cs.algs4.StdOut;
import edu.princeton.cs.algs4.Date;

import java.util.Arrays;

/**
 * 作业 1.2.13 1.2.14
 */
public class Transaction {

    private String name;
    private Date when;
    private double amount;
    Transaction(String transaction) {
        String[] infoString = transaction.split(" ");
        StdOut.println("info" + Arrays.toString(infoString));
        name = infoString[0];

        String[] dateStr = infoString[1].split("/");
        when = new Date(Integer.parseInt(dateStr[0]), Integer.parseInt(dateStr[1]), Integer.parseInt(dateStr[2]));
        amount = Integer.parseInt(infoString[2]);
    }

    public String who() {
        return name;
    }
    public String when() {
        return when.toString();
    }
    public double amount() {
        return amount;
    }

    @Override
    public boolean equals(Object obj) {
        return super.equals(obj);
    }

    public static void main(String[] args) {
        String trans = "菠萝 2024/12/9 100";
        new Transaction(trans);
    }

}
